package com.blog.controller.frontpage;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.blog.controller.base.BaseServlet;
import com.blog.entity.UserEntity;
import com.blog.service.frontpage.UserService;

@WebServlet("/regAjax")
public class RegAjaxServlet extends BaseServlet {

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// 1、 获得昵称
		String phone = req.getParameter("phone");
		// 2、 在注册时进行用户名验证
		UserService service = new UserService();
		UserEntity queryPhone = service.queryUnameForLogin(phone);
		if (queryPhone != null) {
			resp.getWriter().write("用户名已存在！");
		} else {
			resp.getWriter().write("");
		}

	}
}
